﻿using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

using Comswing.Business.Entities;

namespace Comswing.Data.Configuration
{
    internal class OrganizationSwingConfiguration : EntityTypeConfiguration<OrganizationSwing>
    {
        public OrganizationSwingConfiguration()
        {
            HasKey(e => e.Id);

            Property(e => e.Id)
                .IsRequired()
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .HasColumnName("Id");

            HasRequired(e => e.Organization)
                .WithMany(r => r.OrganizationSwings)
                .HasForeignKey(e => e.OrganizationId);

            HasRequired(e => e.Swing)
                .WithMany(r => r.OrganizationSwings)
                .HasForeignKey(e => e.SwingId);

            ToTable("OrganizationSwing", "dbo");
        }
    }
}
